#include <QtCore/QCoreApplication>
#include <DoQuMeasures/BleedThroughTrinarisation.hpp>
#include <QImage>
#include "ImageConverter.hpp"
#include <QImageWriter>
#include <iostream>


#include<QVector>

#include <DoQuMeasures/MesureTemplateMethod.hpp>
#include <DoQuMeasures/EvalBleedThroughIntensity2Ink.hpp>
#include <DoQuMeasures/EvalBleedThroughIntensity2Back.hpp>


#include <DoQuMeasures/EvalBleedThroughVersoQuantity.hpp>
#include <DoQuMeasures/EvalBleedThroughSubstitution.hpp>
#include <DoQuMeasures/EvalBleedThroughSubstitutionGrowing.hpp>
#include <DoQuMeasures/EvalBleedThroughAdd.hpp>
#include <DoQuMeasures/MeasuresFacade.hpp>


#include <QDir>
#include <QFileInfo>
#include <QtGui>

#include "LevenshteinDistance.hpp"
#include "OcrVsTruth.hpp"
#include "OcrToTxt.hpp"
#include "OcrErrorRate.hpp"


#include "ActionOnDirectory.hpp"
#include "ActionBleedThroughEvalOnFile.hpp"


int ocrEval(int argc, char *argv[]);


//#include "NbColumnsOnDoc.hpp"


int main(int argc, char *argv[])
{
    QApplication a(argc,argv);
     //ocrEval(argc,argv);
    //bleedThroughEval(argc,argv);
	MeasuresFacade facade;
	facade.test();


    QString versoPath = "/Users/zoolonly/Pictures/DocSynthetiques/verso2/verso.png";
    ActionOnDirectories<float> d("/Users/zoolonly/Pictures/DocSynthetiques/verso2/");
    ActionOnDirectory<float> d_subs;
    std::cout << "La" << std::endl;
    d.addAction(&d_subs);


    QImage qverso(versoPath);
    qverso = qverso.mirrored(true, false);
    ImageConverter ctrl;
    girl::tools::Image verso= ctrl.convert(qverso);


    OcrErrorRate t0("ocr");
    d_subs.addAction(&t0);

    OcrErrorRate t1("ocrOpus");
    d_subs.addAction(&t1);

    EvalBleedThroughIntensity2Ink intensityEval(verso);
    ActionBleedThroughEvalOnFile action2(intensityEval, versoPath);
    d_subs.addAction(&action2);

    EvalBleedThroughVersoQuantity quantityProba(verso);
    ActionBleedThroughEvalOnFile action3(quantityProba, versoPath);
    d_subs.addAction(&action3);

    
    EvalBleedThroughAdd addEval(verso);
    ActionBleedThroughEvalOnFile action6(addEval,versoPath);
    d_subs.addAction(&action6);

    EvalBleedThroughSubstitution subEval(verso);
    ActionBleedThroughEvalOnFile action7(subEval,versoPath);
    d_subs.addAction(&action7);

    EvalBleedThroughSubstitutionGrowing growingEval(verso);
    ActionBleedThroughEvalOnFile action8(growingEval,versoPath);
    d_subs.addAction(&action8);

    EvalBleedThroughIntensity2Back backEval(verso);
    ActionBleedThroughEvalOnFile action9(backEval,versoPath);
    d_subs.addAction(&action9);

    //OcrToTxt ocrER;
    //d_subs.addAction(&ocrER);

    d.doAction();
    /*LevenshteinDistance dist;
    QString s = "zt";
    QString autre = "abef";
    std::cout << 100*dist.distance(s.toStdString(),autre.toStdString())/std::max(s.size(),autre.size()) << std::endl;*/

    return a.exec();

}

int ocrEval(int argc, char *argv[])
{
    QApplication a(argc,argv);
    //OcrVsTruth t("/Users/zoolonly/Pictures/DocSynthetiques/FondVesale/");
    //t.process();
    //return a.exec();
}
